<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>嵌入字符串</title>
    <script>
      /*
       * 字符串嵌入方式
       */
      let name = "lmx";
      let mystr1 = "你好，${name}";
      let mystr2 = `你好，${name}!再见`;
      //   console.log(mystr1); //你好，${name}
      //   console.log(mystr2); //你好，lmx!再见
      /*
       * 字符串模版定义
       */
      function tagged(formats, ...args) {
        console.log(formats); //["你好，", "！再见。"]
        console.log(args); //["lmx"]
      }
      tagged`你好，${name}！再见。`;
    </script>
  </head>
  <body></body>
</html>
